﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Web;
using System.Web.Security;

namespace OnlineMealOrdering.Extends
{
    public class CustomIdentity : IIdentity
    {
        private FormsAuthenticationTicket _ticket;
        private HttpContext _httpContext = HttpContext.Current;

        public CustomIdentity(FormsAuthenticationTicket ticket)
        {
            this._ticket = ticket;
        }

        public string AuthenticationType
        {
            get { return "CustomIdentity"; }
        }

        public bool IsAuthenticated
        {
            get { return true; }
        }

        public string UserCode
        {
            get { return _ticket.Name; }
        }

        public FormsAuthenticationTicket Ticket
        {
            get { return _ticket; }
        }

        public string UserName
        {
            get { return _ticket.UserData.Split(',')[0]; }
        }

        public string UserId
        {
            get { return _ticket.UserData.Split(',')[1]; }
        }

        public string Name
        {
            get { return _ticket.UserData.Split(',')[0]; }
        }
    }
}